//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<sstream>
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef	vector<int>             VI;
typedef	vector<bool>            VB;
typedef	vector<VI>              VVI;
typedef	vector<string>          VS;
typedef	pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef	pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

#ifdef _DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif

const int MAXN = 1<<17;
int tree[2*MAXN];
int N = MAXN;

int gcd(int a, int b) {
	return (a ? gcd(b%a,a):b );
}

int it = 0;
bool bx;
void add(int a, int pos = it, int L = 0, int R = N-1, int idx = 1) {
	if( bx )
		return ;
	if( L==R ) {
		 tree[idx] = a;
		 return ;
	}
	int mid = (L+R)>>1;
	if( pos<=mid )
		add(a,pos,L,mid,idx<<1);
	else
		add(a,pos,mid+1,R,(idx<<1)+1);
	int new_v = gcd( tree[idx<<1], tree[(idx<<1)+1] );
	if( tree[idx]==new_v )
		bx = true;
	tree[idx] = new_v;
}

void remove(int pos, int L = 0, int R = N-1, int idx = 1) {
	add(0,pos);
}

int main()
{
	int q;
	scanf("%d",&q);
	it = 0;
	map<int,VI > M;
	int c = 0;
	FOR(index_s,0,q) {
		char x;
		int n;
		
		scanf("\n%c%d",&x,&n);
		//cin >> x >> n;
		if( x=='+' ) {
			c++;
			M[n].push_back(it);
			bx = false;
			add(n);
			printf("%d\n",tree[1]);
			it++;
			continue;
		}
		//x == '-'
		c--;
		int place = M[n][SZ(M[n])-1];
		M[n].pop_back();
		bx = false;
		remove(place);
		if( c==0 ) {
			printf("1\n");
			continue;
		}
		printf("%d\n",tree[1]);
	}
    return 0;
}